<template>
	<div class="card-confirm-order-buyBtn">

		<div id="buy-btn" class="buy-btn" :class={'go-gray':isGoGray} @click='toConfirm'>确认提交</div>
		

	</div>
</template>
<script>
import Vue from 'vue';
import { Toast } from 'mint-ui';
	export default {
		data() {
				return {
					isGoGray:false
				}
			},
			props: {
				carinfo:{
					type:Object,
					default:{}
				},
				custominfo:{
					type:Object,
					default:{}
				}
			},
			methods: {
				chooseStore:function(){
					window.location.href='https://www.baidu.com';
				},
				toConfirm: function() {
					var self = this;
                    //车牌
                    var carplate='';
                    var carplateFull=''
                    var isPlate = /^[\u4e00-\u9fa5]{1}[A-Z]{1}[A-Z_0-9]{5}$/; //车牌正则验证
					if (!self.carinfo.disabledPlate) {//当后端没有车牌数据时
						carplate=localStorage.getItem('carplate').trim();
						carplateFull=document.querySelector(".carplate-choose b").innerHTML.trim()+localStorage.getItem('carplate').trim();
                        
                        if (!carplate) {
	                        Toast("亲，请填写车牌号！");
	                        return false;
	                    }
	                    if (!isPlate.test(carplateFull)) {
	                        Toast("车牌格式错误！");
	                        return false;
	                    }
                    }else{
                    	carplateFull=self.carinfo.carPlate;
                    }
                    
                    //联系人
                    var custName='';
                    if(self.custominfo.custName){
                    	custName=self.custominfo.custName;
                    }else{
                    	custName=localStorage.getItem('username').trim();
                    	if (!custName) {
		                    Toast("亲，请填写联系人！");
		                    return false;
		                }
                    }
                    
                    //手机
                    var mobilePhone='';
                    var isMobile = /^[0-9]{11}$/;
                    if(self.custominfo.mobilePhone){
                    	mobilePhone=self.custominfo.mobilePhone;
                    }else{
                    	mobilePhone = localStorage.getItem('phone').trim();
                    	if (!mobilePhone) {
		                    Toast("亲，请填写手机号！");
		                    
		                    return false;
		                }
                    	if (!isMobile.test(mobilePhone)) {
		                    Toast({
							  message: '亲，请填写正确的手机号！',
							  duration: 125000
							});
		                    return;
		                }
                    }
	                
	                //门店
	                if (!localStorage.getItem('storename')) {
	                    Toast("亲，请选择预约门店！");
	                    return false;
	                }
                    
					return true;
				}
			},
			ready: function() {

			}
	}
</script>
<style lang="scss">
	@import "../../assets/css/_functions.scss";
	@import "../../assets/css/_variables.scss";
	@import "../../assets/css/toast.scss";
	body {
		background: #eeeeee!important;
	}
	
	.card-confirm-order-buyBtn {
		font-size: rem(14);
		color: #333;
		.service-list{
				padding-left: rem(14);
				
				background: #fff;
				li{
					display: flex;
					align-items: center;
					width: rem(375);
					height: rem(44);
					border-bottom: 1px solid #eee;
					div:nth-of-type(1){
						background: #ededed;
						width: rem(10);
						height: rem(10);
						border-radius: 100%;
					}
					div:nth-of-type(2){
						font-size: rem(13);
						color: #666;
						padding-left: rem(10);
					}
					
					
				}
				
		}
		
	}
	
	
</style>